<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
  </head>
  <body>
    <div id="app">
      <box-son @to-dad=receive></box-son>
      <div>来自儿子的信息:"{{msg}}"</div>
    </div>
    <script src="./vue.js"></script>
    <script>
      const vm=new Vue({
        el:'#app',
        data:{msg:""},
        methods:{
          receive(e){
            this.msg=e
          }
        },
        components:{
          "box-son":{
            template:`<div>儿子给父亲发短信 <button @click=fn>点击发送</button></div>`,
            methods:{
              fn(){
                this.$emit("to-dad",this.msg)
              }
            },
            data(){
              return {
                msg:"父亲节快乐"
              }
            }
          }

        }
       })
    </script>
  </body>
</html>